(()=>{
    // 多态： 父类型的引用指向子类型的对象

    // 定义一个父类
    class Anaimal {
        name : string 
        constructor(name :string) {
            this.name = name 
        }

        run(distance: number = 0) {
            console.log(`${this.name} 跑了 ${distance}`)
        }
    }


    class Pig extends Anaimal {
        constructor(name :string) {
            super(name)
        }

        run(distance: number = 10) {
            super.run(distance)
        }
    }


    const ani: Anaimal = new Anaimal('动物')
    ani.run() 

    const pig: Anaimal = new Pig('小猪')
    pig.run()

    function showRun(ani: Anaimal) {
        ani.run()
    }

    showRun(ani)
    showRun(pig)

})()